﻿using Commons;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace RMS.Token
{
    public class ApiAuthFilter : Attribute, IActionFilter
    {
        public void OnActionExecuted(ActionExecutedContext context)
        {
            throw new NotImplementedException();
        }

        public void OnActionExecuting(ActionExecutingContext context)
        {
            ResultType result = new ResultType();
            var userid= context.ActionArguments["UserID"];
            var controllername = context.RouteData.Values["controller"];
            var actionname = context.RouteData.Values["action"];
            string apiname = controllername + "/" + actionname;
            result.ResultCode = 401;
            result.ResultMsg = "没有操作权限！";
            context.Result = new JsonResult(result);
            return;

        }
    }
}
